package org.fatmansoft.teach.repository;

import org.fatmansoft.teach.models.Other;
import org.fatmansoft.teach.models.Other;
import org.fatmansoft.teach.models.Teacher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;
public interface OtherRepository extends JpaRepository<Other,Integer>{
    @Query(value = "from Other where ?1='' or person.num like %?1% or person.name like %?1% ")
    List<Other> findOtherListByNumName(String numName);

    @Query(value = "from Other where ?1='' or person.num like %?1% or person.name like %?1% ",
            countQuery = "SELECT count(otherId) from Other where ?1='' or person.num like %?1% or person.name like %?1% ")
    Page<Other> findOtherPageByNumName(String numName, Pageable pageable);
}
